using System;
using OctopusTools.Client;
using OctopusTools.Commands.Infrastructure;

namespace OctopusTools.Commands
{
    public abstract class ApiCommand : ICommand
    {
        readonly IHttpClient httpClient;

        public ApiCommand(IHttpClient httpClient)
        {
            this.httpClient = httpClient;
        }

        public virtual OptionSet Options
        {
            get 
            {
                var options = new OptionSet();
                options.Add("apiKey=", "The API Key from the Settings->API page in your Octopus server.", v => httpClient.ApiKey = v);
                options.Add("server=", "The base URL for your Octopus server - e.g., http://myserver/", v => httpClient.BaseUrl = v);
                return options;
            }
        }

        public abstract void Execute();
    }
}